<?php
$this->breadcrumbs=array(
	'Nhân vật sự kiện'=>array('/Events/artists/index'),
	'Cập nhật',
);
 
?>
<div class="row">
	<div class="col-md-12">
    	<div class="portlet">
        	<div class="portlet-title">
            	<div class="caption"><i class="icon-bar-chart"></i>Nhân vật sự kiện</div>
            </div>
            <div class="portlet-body">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'organizers-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array(
		'class'=>'horizontal-form',
        'enctype'=>'multipart/form-data',  
    ),
)); ?>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->errorSummary($model->profile); ?>
<?php echo $form->errorSummary($model->seotool); ?>
<div class="form-body">
    <div class="row">
    	<div class="col-md-4">
            <fieldset>
        	<legend>Ảnh đại diện nhân vật</legend>
                <!-- Event Image -->
                <div class="fileupload fileupload-new <?php echo ($model->getError('image') ? 'has-error' : ''); ?>" data-provides="fileupload">
                    <div class="fileupload-new thumbnail" style="width: 100%;">
                    <?php if ($model->isNewRecord) : ?>
                        <img src="<?php echo Yii::app()->theme->baseUrl; ?>/img/no_image.gif" alt="" />
                    <?php else : ?>
                        <img src="<?php echo $this->getImageUrl() . 'artists/' . date('Ymd', strtotime($model->createddate)) . '/' . $model->image; ?>" width="100%" />
                    <?php endif; ?>
                    </div>
                    <div class="fileupload-preview fileupload-exists thumbnail" style="width: 100%; line-height: 20px;"></div>
                    <div class="text-center">
                        <span class="btn default btn-file">
                            <span class="fileupload-new"><i class="icon-paper-clip"></i> Select image</span>
                            <span class="fileupload-exists"><i class="icon-undo"></i> Change</span>
                            <?php echo $form->fileField($model, 'image', array('class'=>'default')); ?>
                        </span>
                        <a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="icon-trash"></i> Remove</a>
                    </div>
                    <?php echo $form->error($model, 'image', array('class'=>'help-block')); ?>
                </div>
            </fieldset>
 		</div>
        <div class="col-md-8">
            <fieldset>
        	<legend>Ảnh cover nhân vật</legend>
            <!-- Event Image -->
                <div class="fileupload fileupload-new <?php echo ($model->getError('imagecover') ? 'has-error' : ''); ?>" data-provides="fileupload">
                    <div class="fileupload-new thumbnail" style="width: 100%;">
                    <?php if ($model->isNewRecord) : ?>
                        <img src="<?php echo Yii::app()->theme->baseUrl; ?>/img/no_image.gif" alt="" />
                    <?php else : ?>
                        <img src="<?php echo $this->getImageUrl() . 'artists/' . date('Ymd', strtotime($model->createddate)) . '/' . $model->imagecover; ?>" width="100%" />
                    <?php endif; ?>
                    </div>
                    <div class="fileupload-preview fileupload-exists thumbnail" style="width: 100%; line-height: 20px;"></div>
                    <div class="text-center">
                        <span class="btn default btn-file">
                            <span class="fileupload-new"><i class="icon-paper-clip"></i> Select image</span>
                            <span class="fileupload-exists"><i class="icon-undo"></i> Change</span>
                            <?php echo $form->fileField($model, 'imagecover', array('class'=>'default')); ?>
                        </span>
                        <a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="icon-trash"></i> Remove</a>
                    </div>
                    <?php echo $form->error($model, 'imagecover', array('class'=>'help-block')); ?>
                </div>
            </fieldset>
 		</div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <fieldset>
        	<legend>Thông tin nhân vật</legend>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group <?php echo ($model->getError('nickname') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'nickname', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model,'nickname', array('class'=>'form-control')); ?>
                        <?php echo $form->error($model,'nickname', array('class'=>'help-block')); ?>
                    </div>
                    <div class="form-group <?php echo ($model->getError('fullname') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'fullname', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model,'fullname', array('class'=>'form-control')); ?>
                        <?php echo $form->error($model,'fullname', array('class'=>'help-block')); ?>
                    </div>
                    <div class="form-group <?php echo ($model->getError('email') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'email', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model,'email', array('class'=>'form-control')); ?>
                        <?php echo $form->error($model,'email', array('class'=>'help-block')); ?>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group <?php echo ($model->getError('gender') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'gender', array('class'=>'control-label')); ?>
                        <?php echo $form->dropDownList($model,'gender',array('M'=>'Nam', 'F'=>'Nữ'), array('class'=>'form-control')); ?>
                        <?php echo $form->error($model,'gender', array('class'=>'help-block')); ?>
                    </div>
                    <div class="form-group <?php echo ($model->getError('dateofbirth') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'dateofbirth', array('class'=>'control-label')); ?>
                        <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                            'model'=>$model,
                                            'attribute' => 'dateofbirth',
                                            'language'=>Yii::app()->language=='vi' ? 'vi' : null,
                                            'options'=>array(
                                                'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
                                                'showOn'=>'focus', // 'focus', 'button', 'both'
                                                'buttonImageOnly'=>false,
                                                'showAnim'=>'clip',
                                                'changeMonth'=>true,
                                                'changeYear'=>true,
                                                'showButtonPanel'=>true,
                                                'dateFormat' => "yy-mm-dd",
                                                'buttonImageOnly'=>true,
                                                //'minDate'=>'1000',
                                                'yearRange' => "1940:2010",
                                            ),
                                            'htmlOptions'=>array(
                                                'style'=>'vertical-align:top',
                                                'placeholder'=>"2012-06-20",
                                                'class'=>'form-control'
                                            ),
                                        ));
                        ?>
                        <?php echo $form->error($model,'dateofbirth', array('class'=>'help-block')); ?>
                    </div>
                    <div class="form-group <?php echo ($model->getError('status') ? 'has-error' : ''); ?>">
                        <?php echo $form->labelEx($model,'status', array('class'=>'control-label')); ?>
                        <?php echo $form->dropDownList($model,'status',array('A'=>'Hoạt động','I'=>'Ngừng hoạt động'), array('class'=>'form-control')); ?>
                        <?php echo $form->error($model,'status', array('class'=>'help-block')); ?>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <?php echo $form->labelEx($model->seotool, 'title', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model->seotool, 'title', array('class'=>'form-control input-sm', 'placeholder'=>'')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($model->seotool, 'title'); ?></span>
                    </div>

                    <div class="form-group">
                        <?php echo $form->labelEx($model->seotool, 'description', array('class'=>'control-label')); ?>
                        <?php echo $form->textArea($model->seotool, 'description', array('class'=>'form-control input-sm', 'placeholder'=>'', 'rows'=>5)); ?>
                        <span class="help-block text-danger"><?php echo $form->error($model->seotool, 'description'); ?></span>
                    </div>

                    <div class="form-group">
                        <?php echo $form->labelEx($model->seotool, 'keywords', array('class'=>'control-label')); ?>
                        <?php echo $form->textField($model->seotool, 'keywords', array('class'=>'form-control input-sm', 'placeholder'=>'')); ?>
                        <span class="help-block text-danger"><?php echo $form->error($model->seotool, 'keywords'); ?></span>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <div class="form-group <?php echo ($model->getError('brief') ? 'has-error' : ''); ?>">
                            <?php echo $form->labelEx($model,'brief', array('class'=>'control-label')); ?>
                            <?php echo $form->textArea($model,'brief', array('class'=>'form-control','rows'=>5)); ?>
                            <?php echo $form->error($model,'brief', array('class'=>'help-block')); ?>
                        </div>
                    </div>
                </div>
            </div>
			<div class="form-group <?php echo ($model->profile->getError('description') ? 'has-error' : ''); ?>">
				<?php echo $form->labelEx($model->profile,'description', array('class'=>'control-label')); ?>
				<?php $this->widget('application.extensions.ckeditor.CKEditor', array(
                            'model'=>$model->profile,
                            'attribute'=>'description',
                            'language'=>'vi',
                            'editorTemplate'=>'full',
                            'options'=>array(
                                'height'=>'400px',
                            ),
                            'htmlOptions'=>array('rows'=>20,'class'=>'form-control'),
                        )); ?>
				<?php echo $form->error($model->profile,'description', array('class'=>'help-block')); ?>
			</div>	

			<!-- PLACE SOCIAL -->
			        <div class="col-md-12 row">
			            <div id="listSocial">
			                
			            </div>
						<a href="javascript: void(0);" class="btn green pull-right" onclick="addSocial();"><i class="icon-plus"> </i> Thêm Social</a>
                </div>
          </div>
    </div>
                <?php echo CHtml::submitButton('Lưu', array('class'=>'btn green', 'style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Refresh', array('onClick'=>'window.location="'.Yii::app()->getRequest()->getUrl().'"','class'=>'btn btn-beoro-3','style'=>'margin-right : 10px'));?>
                <?php echo CHtml::submitButton('Back', array('onClick'=>'history.go(-1)','class'=>'btn btn-beoro-3', 'style'=>'margin-right : 10px'));?>
 
<?php $this->endWidget(); ?>
 <script type="text/javascript">
var i = 1;
function addSocial()
{
    $.ajax({
        url: '<?php echo Yii::app()->createUrl("/Events/request/artistsAddSocial");?>',
        type: 'post',
        data: {i: i},
        success: function (data)
        {
             i = i+ 1;
            $(data).appendTo('#listSocial');
        }
    });
}
 </script>
            </div>
        </div>
    </div>
</div>
